<?php

/**
 * This is the model class for table "tbl_companyinfo".
 *
 * The followings are the available columns in table 'tbl_companyinfo':
 * @property string $name
 * @property string $address1
 * @property string $address2
 * @property string $city
 * @property string $state
 * @property string $zip
 * @property string $phone
 * @property string $tollfree
 * @property string $fax
 * @property string $fiscalbeg
 * @property string $fedidnumber
 */
class Companyinfo extends CanLockRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Companyinfo the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_companyinfo';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('name, address1, city, state, zip', 'required'),
			array('name, address1, address2, city', 'length', 'max'=>75),
			array('state', 'length', 'max'=>2),
			array('zip, phone, tollfree, fax, fedidnumber', 'length', 'max'=>12),
			array('fiscalbeg', 'length', 'max'=>25),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('name, address1, address2, city, state, zip, phone, tollfree, fax, fiscalbeg, fedidnumber', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'name' => 'Name',
			'address1' => 'Address1',
			'address2' => 'Address2',
			'city' => 'City',
			'state' => 'State',
			'zip' => 'Zip',
			'phone' => 'Phone',
			'tollfree' => 'Tollfree',
			'fax' => 'Fax',
			'fiscalbeg' => 'Fiscalbeg',
			'fedidnumber' => 'Fedidnumber',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('name',$this->name,true);
		$criteria->compare('address1',$this->address1,true);
		$criteria->compare('address2',$this->address2,true);
		$criteria->compare('city',$this->city,true);
		$criteria->compare('state',$this->state,true);
		$criteria->compare('zip',$this->zip,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('tollfree',$this->tollfree,true);
		$criteria->compare('fax',$this->fax,true);
		$criteria->compare('fiscalbeg',$this->fiscalbeg,true);
		$criteria->compare('fedidnumber',$this->fedidnumber,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}